<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
    <input type="text"><br />
    <input type="text"><br />
    <input type="text"><br />
    <input type="text"><br />
    <input type="text">
  <script>
    //获取元素
    var ipts = document.getElementsByTagName("input");
    //获得焦点事件
    for(var i = 0; i < ipts.length; i++){
      
      ipts[i].onfocus = function(){
        //排他思想，每此点击自己时，先把全部的样式更新一遍
        for(var j = 0; j < ipts.length; j++){
          ipts[j].style.background = "#fff";
        }
        //再给自己添加样式
        this.style.background = "#777";
      }
    }
  </script>
</body>
</html>